<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>

    <link rel="stylesheet" href="css/foodList.css" type="text/css" />
</head>
<body>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Food Detail</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label>Image</label><br/>
                        <img style="width: 200px; height: 200px" id="image-modal">
                    </div>
                    <div class="form-group">
                        <input type="hidden" name="id">
                        <label>Food Name</label>
                        <input type="text" class="form-control" name="name">
                    </div>
                    <div class="form-group">
                        <label>Food Price</label>
                        <input type="text" class="form-control" name="price">
                    </div>
                    <div class="checkbox">
                        <label>
                            <input type="hidden">
                        </label>
                    </div>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" id="addFoodToCart">Add Cart</button>
            </div>
        </div>
    </div>
</div>
<!--食物展示模板-->
<div id="food-model" class="show-food-list-sample hidden-food-pattern">
    <div class="thumbnail">
        <div id="food-img-div" class="thumbnail">
            <img class="food-image" src="adv1.jpg" alt="...">
        </div>
        <div class="caption food-info-div">
            <h3>food Name</h3>
            <p>food price</p>
            <a class="btn btn-primary btn-lg show-food-detail" data-toggle='modal' data-target='#myModal'>Detail</a>
            <a class="btn btn-primary btn-lg show-food-detail" onclick="addToCart($(this))">&nbsp;&nbsp;Add&nbsp;</a>
        </div>
    </div>
</div>
<div id="main-div">
    <!-- 上方标题-->
    <div class="top-title">
        <div class="dole-logo log-div">
            <a href="">
                <img src="img/login.jpg" alt="Angers">
            </a>
        </div>
        <div class="title-nav">
            <div class="page-header page-header-div">
                <h1>Example page header
                    <small>Subtext for header</small>
                </h1>
            </div>
            <div class="admin-center">
                <img src="http://ZHA-ITA077-w7/${customer.avatar}" class="img-rounded" height="70" width="70">
                <div class="btn-group user-center-btn-group">
                    <button type="button" class="btn btn-primary btn-lg">UserName</button>
                    <button type="button" class="btn btn-primary dropdown-toggle btn-lg " data-toggle="dropdown"
                            aria-haspopup="true" aria-expanded="false">
                        <span class="caret"></span>
                        <span class="sr-only">Toggle Dropdown</span>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="#">UserCenter</a></li>
                        <li><a href="#">AddressManager</a></li>
                        <li><a href="#">Change Avater</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">Log Out</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!-- 菜单栏-->
    <div class="bottom-menu-operationarea">
        <div id="left-menu-log" class="mac-main-nav menu-div">
            <!--选项栏-->
            <div class="console-menu">
                <ul class="nav nav-pills nav-stacked">
                    <li crole="presentation" class="menu-li active"><a href="merchantList.jsp">HomePage</a></li>
                    <li role="presentation" class="menu-li"><a href="orderPage.html">Orger Page</a></li>
                </ul>
            </div>
            <div id="merchant-display" class="row">
                <input id="merchant-id-holder" type="hidden" value=${merchant.id }>
                <div class="col-sm-10 col-md-11">
                    <div class="thumbnail">
                        <a id="food-img" href="javascript:void(0);" class="thumbnail">
                            <img src="http://ZHA-ITA077-w7/${merchant.avatarPath }" alt="...">
                        </a>
                        <div class="caption">
                            <h3>${merchant.name }</h3>
                            <p>${merchant.address }</p>
                        </div>
						<div>
							 <a id="lokup-comment" class="btn btn-primary btn-sm" href="comment.jsp?id=${merchant.id }">Lookup Comment</a>
						</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="operationarea">
        <div id="food-type-choose-nav">
            <ul id="category-list" class="nav nav-pills">
                <!--  <li role="presentation" class="active"><a href="#">All Food</a></li>
                 <li role="presentation"><a href="#">Set Meal</a></li>
                 <li role="presentation"><a href="#">Staple food</a></li>
                 <li role="presentation"><a href="#">Drinks</a></li>
                 <li role="presentation"><a href="#">Snacks</a></li> -->
            </ul>

        </div>
        <div class="div-cart-icon">
            <button type="button" class="btn btn-success show-carticon-btn" aria-label="Left Align">
                <span class="glyphicon glyphicon-shopping-cart " aria-hidden="true"></span>
                <span class="point"></span>
            </button>
        </div>
        <div id="cart-body">
            <span id="cart-body-top" style="color: #ffffff">购物车</span>
            <div id="cart">
                <c:forEach items="${sessionScope.orderList}" var="order">
                    <ul class="list-ul">
                        <li class="food_name">${order.name}</li>
                        <li>${order.price}</li>
                        <li>
                            <button class="btn btn-default btn-xs" onclick='del($(this))'>-</button>
                            <span>${order.amount}</span>
                            <button class="btn btn-default btn-xs" onclick='up($(this))'>+</button>
                        </li>
                    </ul>
                </c:forEach>
            </div>
            <div id="sum" style="line-height: 40px"></div>
            <button type="button" class="btn btn-success take_order_btn">结算</button>
        </div>
        <input type="hidden" value="${merchantId}">
        <div id="show-food-area">
        </div>
    </div>
</div>

<script type="text/javascript" src="js/application.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/foodList.js"></script>
<script type="text/javascript" src="js/showFoodList.js"></script>
<script type="text/javascript" src="js/urlUtil.js"></script>
<script type="text/javascript">
    /*页面初始化*/
    $(function () {
        var mainPage = new merchantFoodList($("#category-list"), $("#show-food-area"));
        mainPage.findAllCategories();
        mainPage.findFoods("all");

        //添加动作
        $(".show-carticon-btn").on("click", function () {
            $("#cart-body").slideToggle(1000);
        });

        $(".take_order_btn").on("click", function () {
            window.location.href = "orderPage?merchantId=" + $("#merchant-id-holder").attr("value");
        });

        $("#addFoodToCart").on("click", function () {
            addToCartFromModal($(this));
            $("#myModal").modal("hide");
        });

        // 前端计算
        count();
    });
</script>
</body>
</html>